package GameSrc;

import java.awt.*;
import java.util.ArrayList;

import static java.lang.Math.*;

public class Fort extends GameObject{

    private int integral;


    public Fort() {
    }

    public Fort( int x, int y, GameWindow gameWindow,int integral) {
        super(1024,205, x, y, "Game/img/fort.png", gameWindow);
        this.integral=integral;
    }

    public int split(int i){
        int goal=0;
        int t=integral;
        if (integral/(int) pow(10,i)!=0){
            for (int j = 0; j < i+1; j++) {
                goal=t%10;
                t/=10;
            }
            return goal;
        }
        return 0;
    }


    public void paintFort(Graphics g){
        g.drawImage(this.getImg(),this.getX(),this.getY(),this.getGameWindow());
        ArrayList<Num> numS = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            numS.add(new Num(400-24*i,533,"Game/img/num/"+split(i)+".png",this.getGameWindow()));
            g.drawImage(numS.get(i).getImg(), numS.get(i).getX(), numS.get(i).getY(), numS.get(i).getGameWindow());
        }

    }

}
